package com.tepth.remote.core.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.FrameLayout;

import com.tepth.remote.core.R;
import com.tepth.remote.core.delegates.BaseControlDelegate;

import me.yokeyword.fragmentation.SupportActivity;

/**
 * Description:基础Activity
 *
 * @author Hequn.Lee
 * @date 2018/11/7
 */
public abstract class BaseProxyActivity extends SupportActivity {

    /**
     * 设置启动页Delegate
     *
     * @return 返回启动页Delegate
     */
    public abstract BaseControlDelegate setLauncherDelegate();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initContainer(savedInstanceState);
    }

    private void initContainer(@Nullable Bundle savedInstanceState) {
        final FrameLayout container = new FrameLayout(this);
        container.setId(R.id.delegate_container);
        setContentView(container);
        if (savedInstanceState == null) {
            loadRootFragment(R.id.delegate_container, setLauncherDelegate());
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        System.gc();
        System.runFinalization();
    }
}
